import { lazy } from "react";
import { createBrowserRouter } from "react-router-dom";
const Home = lazy(() => import("../pages/home/Index"));
import Index from "../pages/home/Index";
import Login from "../pages/login/Index";
import My from "../pages/my/Index";
import User from "../pages/user/Index";
import Error from "../pages/404/Index";
import App from "../App";

export const erji = [
  {
    path: "/home/index",
    title: "首页",
    element: <Index />,
    children: [
      {
        path: "/home/index/user",
        element: <User />,
      },
    ],
  },
  {
    path: "/home/my",
    title: "我的",
    element: <My />,
  },
];

const router = createBrowserRouter([
  {
    path: "/",
    element: <App />,
    children: [
      {
        index: true,
        element: <Home />,
      },
      {
        path: "/home",
        element: <Home />,
        children: erji,
      },
    ],
  },
  {
    path: "/login",
    element: <Login />,
  },
  {
    path: "*",
    element: <Error />,
  },
]);
export default router;
